package com.okami.clazz;

import sun.reflect.Reflection;

import java.lang.reflect.Constructor;
import java.lang.reflect.Type;

/**
 * @author: TanJingyu
 * @create: 2021-01-20 17:49
 **/
class MainTest {
    public static void main(String[] args) throws Exception {
        ClassObject object = new ClassObject();
        Class<? extends ClassObject> oc = object.getClass();
//
//        // Father.class分配出oc。。。true
//        Father.class.isAssignableFrom(oc);
//
//        /**
//         *  Constructor 构造方法
//         */
//        // 获取所有符合参数条件的构造函数
//        Constructor<? extends ClassObject> declaredConstructor = oc.getDeclaredConstructor(String.class);
//        // 获取符合参数条件的public构造函数
//        Constructor<? extends ClassObject> constructor = oc.getConstructor();
//        // 获取所有public构造函数
//        Constructor<?>[] constructors = oc.getConstructors();
//        // 获取所有构造函数
//        Constructor<?>[] declaredConstructors = oc.getDeclaredConstructors();
//        Class<?>[] exceptionTypes = constructor.getExceptionTypes();
//        Type[] genericExceptionTypes = constructor.getGenericExceptionTypes();

    }

    static class ClassObject extends Father{
        private String userName;
        private Integer age;

        public ClassObject() throws NoSuchFieldException{}

        ClassObject(String userName) {
            this.userName = userName;
        }

        public String getUserName() {
            return userName;
        }

        public void setUserName(String userName) {
            this.userName = userName;
        }

        public Integer getAge() {
            return age;
        }

        public void setAge(Integer age) {
            this.age = age;
        }
    }

    static class Father {

    }
}
